package com.example.safeassistan.home.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.home.model.BackLogFragmentModel;

import java.util.List;

public class BackLogFragmentAdapter extends BaseQuickAdapter<BackLogFragmentModel.ResultDTO.RecordsDTO,BaseViewHolder> {
    private int type=0;

    public BackLogFragmentAdapter(@Nullable List<BackLogFragmentModel.ResultDTO.RecordsDTO> data,int type) {
        super(R.layout.item_backlog_fragment, data);
        this.type=type;
    }

    @Override
    protected void convert(BaseViewHolder helper, BackLogFragmentModel.ResultDTO.RecordsDTO item) {
        ImageView ivImg=helper.getView(R.id.ivImg);
        TextView tvCheck=helper.getView(R.id.tvCheck);
        switch (type){
            case 1:
                tvCheck.setText("检查");
                break;
            case 0:
                tvCheck.setText("查看");
                break;
        }
        helper.setText(R.id.tvName,item.getRiskPointName()+"("+item.getNum()+")");

       Glide.with(mContext).load(item.getRiskPointImg())
               .placeholder(R.mipmap.default_image)
               .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
               .into(ivImg);
    }
}
